console.log('----');
// 发请求，获取天气预报的数据
var req = new XMLHttpRequest();
req.onreadystatechange = function(){
    console.log(req.readyState);
    if(req.readyState == 4){
        console.log(req.responseText);
        var data = JSON.parse(req.responseText);
        console.log(data);
        // 把数据展示到页面上
        var city = data.results[0].currentCity;
        console.log(city);
        var pm25 = data.results[0].pm25;
        console.log(pm25);
        // 提前在html中把页面布局完成
        // 在这里查找每一个标签，修改内容
        document.querySelector('h1').innerHTML = city;
        document.querySelector('strong').innerHTML = pm25;
        
        //
        var weatherData = data.results[0].weather_data;
        console.log(weatherData);
        var ul = document.createElement('ul');
        document.body.appendChild(ul); 
        for(var i = 0 ; i < weatherData.length ;i++){
            var li = document.createElement('li');
            var date = weatherData[i].date ;
            var wind = weatherData[i].wind;
            var pic = weatherData[i].dayPictureUrl;
            li.innerHTML = date + ' ' + wind ;
            var img = document.createElement('img');
            img.src = pic ;
            li.appendChild(img);
            ul.appendChild(li);
        }

    }
}
req.open('POST','api/goods.php');
req.send();

